import request from './request.js'
const http = request({
	baseURL: 'https://xxx.com',
	timeout: 10000,
	header: {
		
	}
})

// 请求拦截
http.interceptors.request.use(async (config, ...args) => {
    // await new Promise(resolve => setTimeout(() => resolve(), 3000)) 
	// args[0] method args[1] url args2] data
    return config
})
// 响应拦截
http.interceptors.response.use(async (response, ...args) => {
    const { data: res } = response // args[0] method args[1] url args[3] data
    // await new Promise(resolve => setTimeout(() => resolve(), 3000))
    if (res.code === 0) {
        return response
    }
    
})

export default http